-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[libFuzzer] always install signal handler with SA_ONSTACK #147422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
SA_ONSTACK is required for certain runtimes that use small stacks, for instance the Go runtime. See golang/go#49075 SA_ONSTACK is a no-op unless someone also calls sigaltstack.
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Keith Randall (randall77) ChangesSA_ONSTACK is required for certain runtimes that use small stacks, for instance the Go runtime. Full diff: https://github.com/llvm/llvm-project/pull/147422.diff 1 Files Affected:
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
index 392c1e5be4eea..b6cc3bcf8a3f3 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilPosix.cpp
@@ -78,10 +78,14 @@ static void SetSigaction(int signum,
}
struct sigaction new_sigact = {};
- // Address sanitizer needs SA_ONSTACK (causing the signal handler to run on a
- // dedicated stack) in order to be able to detect stack overflows; keep the
- // flag if it's set.
- new_sigact.sa_flags = SA_SIGINFO | (sigact.sa_flags & SA_ONSTACK);
+ // SA_ONSTACK is required for certain runtimes that use small stacks, for
+ // instance the Go runtime.
+ // See https://github.com/golang/go/issues/49075
+ // Address sanitizer also wants SA_ONSTACK, and the fuzzer and sanitizer
+ // often run together.
+ // SA_ONSTACK is a no-op unless someone also calls sigaltstack. That is left
+ // up to code that needs it.
+ new_sigact.sa_flags = SA_SIGINFO | SA_ONSTACK;
new_sigact.sa_sigaction = callback;
if (sigaction(signum, &new_sigact, nullptr)) {
Printf("libFuzzer: sigaction failed with %d\n", errno);
|
Previous patch and discussion on Phabricator. It's been a few years, trying to get this landed. https://reviews.llvm.org/D150231 Why this matters: it causes random stack corruption in Go when running with libFuzzer. See golang/go#49075 (comment) and subsequent comments. |
Like I said on the old Phabricator discussion, I think this is good to go in. However, I don't have rights to formally approve or merge 🤷♂️ |
Ping. |
It looks like it breaks fuzzer-timeout test on our bot : https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-cmake-RA-expensive/4903/ |
With this change the test fails to walk the stack:
Can I suggest reverting and investigating? |
Sorry about that. What is the workflow for a revert? |
On Vitaly's merge line above there's a 'revert' button. Or not, if you don't have merge permissions - in which case I can do it for you. If you can revert, add a short 'why' comment to it. |
…ONSTACK" (#153114) Reverts llvm/llvm-project#147422 Seems to be causing problems with tracebacks. Probably the trackback code doesn't know how to switch back to the regular stack after it gets to the top of the signal stack.
SA_ONSTACK is required for certain runtimes that use small stacks, for instance the Go runtime.
See golang/go#49075
SA_ONSTACK is a no-op unless someone also calls sigaltstack.